import React from "react";
import { inject, observer } from "mobx-react";

@inject('edcAnalysisDesignerStore', 'routing')
@observer
export default class BoardWidgetEditor extends React.Component {
  constructor(props) {
    super();

    this.store = props.edcAnalysisDesignerStore;
  }

  render() {
    if (!window.weaEdcBoard) return null;

    const { board } = this.store;
    const { BoardWidgetEditor }  = window.weaEdcBoard.com;
    const { params } = this.props;
    const isEdit = 'edit' === params.actionType;
    
    return (
      <BoardWidgetEditor
        disableDataModelChange={true}
        defaultDataModelIds={isEdit ? '' : board.dataModelIds.split(',')}
        params={params}        
      />
    );
  }
}